<!DOCTYPE html>
<html lang="en">

<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<title></title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
	<meta name="description" content="">
	<meta name="author" content="">
	<!-- STYLESHEETS -->
	<!--[if lt IE 9]><script src="../../js/flot/excanvas.min.js"></script><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script><![endif]-->
	<link rel="stylesheet" type="text/css" href="../../css/cloud-admin.css">
	<link rel="stylesheet" type="text/css" href="../../css/themes/default.css" id="skin-switcher">
	<link rel="stylesheet" type="text/css" href="../../css/responsive.css">
	<link href="../../font-awesome/css/font-awesome.min.css" rel="stylesheet">
	<!-- file-input -->
	<link rel="stylesheet" type="text/css" href="../../js/file-input/fileinput.css" />
	<!-- datatable -->
	<link rel="stylesheet" href="../../js/datatables/datatable.css">
	<!-- WIZARD -->
	<link rel="stylesheet" type="text/css" href="../../js/bootstrap-wizard/wizard.css" />
	<!-- SELECT2 -->
	<link rel="stylesheet" type="text/css" href="../../js/select2/select2.min.css" />

</head>

<body>
	<header class="navbar clearfix" id="header">
	</header>

	<!-- PAGE -->
	<section id="page">
		<!-- SIDEBAR -->
		<div id="sidebar" class="sidebar">
			<div class="sidebar-menu nav-collapse">

				<!-- SIDEBAR MENU -->
				<ul>


				</ul>
				<!-- /SIDEBAR MENU -->
			</div>

		</div>
		<!-- /SIDEBAR -->
		<div id="main-content">
			<!-- SAMPLE BOX CONFIGURATION MODAL FORM-->
			<div class="modal fade" id="order_config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
				aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title">订单发货状态确认</h4>
						</div>
						<div class="modal-body">
							<div class="form-group">
								<label class="control-label col-md-3" style="line-height:34px;">您已经确认过订单的发货状态？</label>
							</div>
						</div>

						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">未发货</button>
							<button type="button" class="btn btn-success bt-save">已发货</button>
						</div>
					</div>
				</div>
			</div>
			<div class="modal fade" id="returnMoney_config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
				aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title">退款确认</h4>
						</div>
						<div class="modal-body" style="height:384px">
							<div class="form-group col-md-12" style="margin-bottom:0px;line-height:34px;">
								<label class="control-label col-md-3">订单金额：</label>
								<div class="col-md-4 totalPrice">

								</div>
							</div>
							<div class="form-group col-md-12" style="margin-bottom:0px;line-height:34px;">
								<label class="control-label col-md-3">退货商品金额：</label>
								<div class="col-md-4 returnPrice">

								</div>
							</div>
							<div class="form-group col-md-12" style="margin-bottom:0px;line-height:34px;">
								<label class="control-label col-md-3">应退金额：</label>
								<div class="col-md-4 productPrice">

								</div>
							</div>
							<div class="form-group col-md-12" style="margin-bottom:0px;line-height:34px;">
								<label class="control-label col-md-3">应退成长基金:</label>
								<div class="col-md-4 accountPrice">

								</div>
							</div>

							<div class="form-group col-md-12" style="margin-bottom:0px;line-height:34px;">
								<label class="control-label col-md-3">商家订单号：</label>
								<div class="col-md-4 orderPayCode">

								</div>
							</div>
							<div class="form-group col-md-12" style="margin-bottom:0px;line-height:34px;">
								<label class="control-label col-md-3">退款渠道：</label>
								<div class="col-md-4 payType">

								</div>
								<input type="hidden" name="returnPayType" value="" />
							</div>
							<div class="form-group col-md-12" style="margin-bottom:0px;line-height:34px;">
								<label class="control-label col-md-3"><span class="required">*</span>实退金额：</label>
								<div class="col-md-4 realPrice">
									<input class="form-control" placeholder="请输入实退金额" onkeypress="return $.IsDecimal(event);"
										onblur="return $.IsMoney(this);" onfocus="this.select()" style="height:30px;width:200px;"
										type="text" name="realPrice" />
								</div>
							</div>

							<div class="form-group col-md-12" style="margin-bottom:0px;line-height:34px;">
								<label class="control-label col-md-3"><span class="required">*</span>实退成长基金：</label>
								<div class="col-md-4 realFundPrice">
									<input class="form-control" placeholder="请输入实退成长基金" style="height:30px;width:200px;" type="text"
										name="realFundPrice" onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);"
										onfocus="this.select()" />
								</div>
							</div>

							<div class="form-group col-md-12">
								<label class="control-label col-md-3" style="line-height:34px;"><span
										class="required">*</span>退款备注：</label>
								<div class="col-md-4">
									<textarea name="remark" placeholder="请输入退款备注" class="form-control"
										style="width:280px;resize:none;"></textarea>

								</div>
							</div>
							<div class="form-group col-md-12" style="margin-bottom:0px;line-height:34px;">
								<label class="control-label col-md-7"><span style="color:red;white-space :nowrap ;display:none;">
										(小程序、支付宝不退现金，需要按照原方式先退款)</span></label>

							</div>
						</div>

						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
							<button type="button" class="btn btn-success bt-updateMoney">保存</button>
						</div>
					</div>
				</div>
			</div>
			<div class="container">
				<div class="row">
					<div id="content" class="col-lg-12">
						<!-- PAGE HEADER-->
						<div class="row">
							<div class="col-sm-12">
								<div class="page-header">
									<!-- STYLER -->

									<!-- /STYLER -->
									<!-- BREADCRUMBS -->
									<ul class="breadcrumb">
										<li>
											<i class="fa fa-home"></i>
											<a href="index.html">首页</a>
										</li>
										<li>
											<a href="#">订单管理</a>
										</li>
										<li>订单详情</li>
									</ul>
									<!-- /BREADCRUMBS -->

								</div>
							</div>
						</div>
						<!-- /PAGE HEADER -->
						<!-- SAMPLE -->

						<div class="row">
							<div class="col-md-12" style="background-color:#ffffff">
								<div class="box" style="margin-top:10px">
									<div class="box-title" style="border-bottom:1px solid #5e87b0;line-height:38px">
										<h4><i class="fa fa-file" style="color:red"></i>基本信息</h4>
										<a class="btn btn-default" href="return_order_list.html" style="float:right">返回订单列表</a>
									</div>
									<div class="box-body">
										<div class="form-group  mrg-bt10">
											<label class="control-label col-md-2 " style="width:110px">申请单编号：</label>
											<div class="col-md-2 inline" id="returnCode" style="width:110px">
											</div>
											<label class="control-label col-md-2 " style="width:100px">订单编号：</label>
											<div class="col-md-2 inline" id="orderId" style="width:110px">
											</div>
											<label class="control-label col-md-2 " style="width:70px">类型：</label>
											<div class="col-md-2 inline" id="returnType" style="width:70px">
											</div>
											<label class="control-label col-md-2 " style="width:70px">状态：</label>
											<div class="col-md-2 inline" id="returnStatus" style="width:110px">
											</div>
											<label class="control-label col-md-2 " style="width:100px">申请时间：</label>
											<div class="col-md-2 inline" id="createTime">
											</div>
										</div>
										<div class="form-group  mrg-bt10">
											<label class="control-label col-md-2 " style="width:100px">收货电话：</label>
											<div class="col-md-1 inline" id="orderTelPhone">
											</div>
											<label class="control-label col-md-2" style="width:100px;color:red">申请原因：</label>
											<div class="col-md-4 inline" id="returnReasonType" style="color:red">
											</div>
										</div>
									</div>
								</div>
								<div class="box div_change" style="display:none">
									<div class="box-title" style="border-bottom:1px solid #5e87b0">
										<h4><i class="fa fa-user" style="color:#eea236"></i>收货信息</h4>
									</div>
									<div class="box-body">
										<div class="form-group mrg-bt10">
											<label class="control-label col-md-2" style="width:100px">收货人：</label>
											<div class="col-md-2 inline" id="receiver">
											</div>
											<label class="control-label col-md-2" style="width:100px">电话：</label>
											<div class="col-md-2 inline" id="telPhone">
											</div>
											<label class="control-label col-md-2" style="width:100px">地址：</label>
											<div class="col-md-3 inline" id="address">
											</div>
										</div>

									</div>
								</div>
								<div class="box div_sourceproduct">
									<div class="box-title" style="border-bottom:1px solid #5e87b0">
										<h4><i class="fa fa-archive" style="color:#468847"></i>原商品信息</h4>
									</div>
									<div class="box-body">
										<div class="form-group" style="height:auto;">
											<table id="source_sku_list" class="table table-bordered">
												<thead>
													<tr>
														<th>商品名称</th>
														<th>SKU编码</th>
														<th>颜色/规格</th>
														<th>尺码</th>
														<th>单价</th>
														<th>明细状态</th>
														<th>退款状态</th>

													</tr>
												</thead>
												<tbody>
												</tbody>
											</table>
										</div>
									</div>
								</div>
								<div class="box div_product">
									<div class="box-title" style="border-bottom:1px solid #5e87b0">
										<h4><i class="fa fa-archive" style="color:#468847"></i>退换商品信息</h4>
									</div>
									<div class="box-body">
										<div class="form-group" style="height:auto;">
											<table id="sku_list" class="table table-bordered">
												<thead>
													<tr class='sl-head'>
														<th>商品名称</th>
														<th>SKU编码</th>
														<th>颜色/规格</th>
														<th>尺码</th>
														<th>单价</th>
														<th>数量</th>
														<th class='sds' style="display: none">明细状态</th>
														<th class='srs' style="display: none">退款状态</th>
														<th class='wis' style="display: none">处理方式</th>
														<th class='wis' style="display: none">操作</th>

													</tr>
												</thead>
												<tbody>
												</tbody>
											</table>
										</div>
									</div>
								</div>
								<div class="box div_return" style="display:none">
									<div class="box-title" style="border-bottom:1px solid #5e87b0">
										<h4><i class="fa fa-rmb" style="color:#9db36a"></i>退款信息</h4>
									</div>
									<div class="box-body">
										<div class="form-group  mrg-bt10">
											<label class="control-label col-md-2" style="width:110px">订单金额：</label>
											<div class="col-md-2 inline" id="totalPrice" style="width: 100px">
											</div>

											<label class="control-label col-md-2" style="width:130px">退货总金额：</label>
											<div class="col-md-2 inline" id="productPrice" style="width:130px">
											</div>

											<label class="control-label col-md-2" style="width:100px">应退金额：</label>
											<div class="col-md-2 inline" id="returnPrice">
											</div>

											<label class="control-label col-md-2" style="width:130px">应退成长基金：</label>
											<div class="col-md-2 inline" id="accountPrice" style="width:130px">
											</div>

										</div>
										<div class="form-group  mrg-bt10">
											<label class="control-label col-md-2" style="width:110px">退款渠道：</label>
											<div class="col-md-2 inline" id="payType" style="width: 100px">
											</div>

											<label class="control-label col-md-2" style="width:130px">商家订单号：</label>
											<div class="col-md-2 inline" id="orderPayCode" style="width:130px">
											</div>
											<div id="refundPriceShow">
												<label class="control-label col-md-2" style="width:110px">实退金额：</label>
												<div class="col-md-2 inline" id="refundPrice">
												</div>
											</div>
											<div id="refundAccountPriceShow">
												<label class="control-label col-md-2" style="width:130px">实退成长基金：</label>
												<div class="col-md-2 inline" id="refundAccountPrice" style="width:130px">
												</div>
											</div>
										</div>
										<div class="form-group  mrg-bt10">
											<label class="control-label col-md-2" style="width:100px">退款时间：</label>
											<div class="col-md-2 inline" id="refundTime" style="width:150px">
											</div>

											<label class="control-label col-md-2" style="width:110px">操作人：</label>
											<div class="col-md-2 inline" id="updateBy">
											</div>
											<div class="col-md-2">
													<a class='btn btn-danger btn-xs btn-width bt-retrunMoney'><i class='fa fa-arrow-circle-o-up'></i>退款确认</a>
											</div>
										</div>
									</div>
								</div>
								<div class="box">
									<div class="box-title" style="border-bottom:1px solid #5e87b0">
										<h4><i class="fa fa-info-circle" style="color:#d9edf7"></i>问题信息</h4>
									</div>
									<div class="box-body">
										<div class="form-group  mrg-bt10 returnReason" style="color: red;font-weight: bold">

										</div>
										<div class="form-group  mrg-bt10 returnImgPath" style="display:inline">


										</div>
									</div>
								</div>
								<div class="box div_change" style="display:none">
									<div class="box-title" style="border-bottom:1px solid #5e87b0">
										<h4><i class="fa fa-truck" style="color:#d9edf7"></i>物流信息</h4>
									</div>
									<div class="box-body">
										<div class="form-group  mrg-bt10">
											<label class="control-label col-md-2" style="width:150px">用户寄出物流公司：</label>
											<div class="col-md-2 inline" id="userExpressCompany">
											</div>
											<label class="control-label col-md-2" style="width:150px">用户寄出物流单号：</label>
											<div class="col-md-2 inline" id="userExpressCode">
											</div>
										</div>
										<div class="form-group  mrg-bt10 logisticsList">
											<label class="control-label col-md-2" style="width:100px">物流公司：</label>
											<div class="col-md-2 inline" id="expressCompany">
											</div>
											<label class="control-label col-md-2" style="width:100px">物流单号：</label>
											<div class="col-md-2 inline" id="expressCode">
											</div>

										</div>
									</div>
								</div>
								<div class="box div_returnlog">
									<div class="box-title" style="border-bottom:1px solid #5e87b0">
										<h4><i class="fa fa-smile-o" style="color:#fcd76a"></i>进度跟踪</h4>
									</div>
									<div class="box-body">
										<table id="log_list" class="table table-bordered">
											<thead>
												<tr>
													<th style="width:15%">操作时间</th>
													<th style="width:55%">描述</th>
													<th style="width:20%">备注</th>
													<th style="width:10%">操作人</th>

												</tr>
											</thead>
											<tbody>
											</tbody>
										</table>
									</div>
								</div>
								<div class="box div_yijian">
									<div class="box-title" style="border-bottom:1px solid #5e87b0">
										<h4><i class="fa fa-smile-o" style="color:#fcd76a"></i>审批意见</h4>
									</div>
									<div class="box-body">
										<textarea name="returnremark" placeholder="请输入审批意见" class="form-control"
											style="width:280px;resize:none;"></textarea>
									</div>
								</div>
								<div class="box div_yijian">
									<button type="button" class="btn btn-danger" status="reject">拒绝</button>
									<button type="button" class="btn btn-success" status="pass">通过</button>
								</div>

							</div>
						</div>

						<!-- /SAMPLE -->

						<div class="footer-tools">
							<span class="go-top">
								<i class="fa fa-chevron-up"></i> Top
							</span>
						</div>
					</div>
					<!-- /CONTENT-->
				</div>
			</div>
		</div>
	</section>
	<!--/PAGE -->
	<!-- JAVASCRIPTS -->
	<!-- Placed at the end of the document so the pages load faster -->
	<!-- JQUERY -->
	<script src="../../js/jquery/jquery-2.0.3.min.js"></script>

	<!-- BOOTSTRAP -->
	<script src="../../bootstrap-dist/js/bootstrap.min.js"></script>
	<!--bootbox-->
	<script type="text/javascript" src="../../js/bootbox/bootbox.min.js"></script>
	<!-- COOKIE -->
	<script type="text/javascript" src="../../js/jQuery-Cookie/jquery.cookie.min.js"></script>
	<!-- SELECT2 -->
	<script type="text/javascript" src="../../js/select2/select2.min.js"></script>
	<!-- CUSTOM SCRIPT -->
	<script src="../../js/script.js"></script>
	<script src="../../js/common.js"></script>

	<script>
		var AddDetail = function () {
			var id, userId, orderStatus, oId, wdtCode, telPhone, returnType, returnStatus;
			var allSend = true;
			var btnFlag = false;
			var getStatusDesc = function (returOrderStatus) {
				var str = "";
				switch (returOrderStatus) {
					case "WaitingReturnGoods": str = "待退货"; break;
					case "WaitingReturnMoney": str = "待退款"; break;
					case "WaitingInStock": str = "待入库"; break;
					case "WaitingCheck": str = "待审核"; break;
					case "WaitingSend": str = "待发货"; break;
					case "WaitingSign": str = "待签收"; break;
					case "Complete": str = "已完成"; break;
					case "Reject": str = "审批未通过"; break;
					case "Cancel": str = "已取消"; break;
				}
				return str;
			};

			var getDetail = function (returnCode, userId, oId) {
				$.ajax({
					type: "get",
					url: App.getContextPath() + "admin/returnorder/returnorderDetail.do",
					data: {
						returnCode: returnCode, userId: userId
					},
					async: true,
					success: function (result) {
						if (result != null) {
							returnStatus = result.returnStatus;
							returnType = result.returnType;
							if (returnStatus != 'WaitingReturnMoney') {
								$('.bt-retrunMoney').remove()
							}
							$('.bt-retrunMoney').attr('id',result.id)
							//判断退货类型
							if (result.returnType == "Return") {//退货
								$(".div_return").show();
								$("#returnType").html("退货");
								$(".div_sourceproduct").hide();

							} else {//换货
								$(".div_change").show();
								$("#returnType").html("换货");
								$(".div_sourceproduct").show();
								if (result.returnStatus == "WaitingCheck" || result.returnStatus == "WaitingReturnGoods") {
									$(".div_change").hide();
								}
								$.each(result.sourceDetailList, function (index, item) {
									var tr = "<tr><td>" + item.productName + "</td><td>" + item.sourceSkuCode + "</td><td>" + item.shortName + "</td><td>" + item.sourceSizeName + "</td><td>" + (item.price == null ? "" : format_thousands(item.price)) + "</td><td>" + item.orderDetailStatusStr + "</td><td>" + item.refundStatusStr + "</td></tr>";
									$("#source_sku_list tbody").append(tr);
								});
							}
							if (result.returnStatus == "Reject") {
								$(".div_change").hide();
							}
							$("#returnCode").html(returnCode);
							$("#orderId").html("<a  href='../order/order_detail.html?id=" + result.orderId + "'>" + result.orderId + "</a>");
							$("#returnStatus").html(getStatusDesc(result.returnStatus));
							if (result.returnStatus == "WaitingReturnMoney") {
								$("#refundPriceShow").hide();
								$("#refundAccountPriceShow").hide();
							}
							$("#createTime").html($.getLocalTime(result.createTime));
							$("#receiver").html(result.receiver);
							$("#telPhone").html(result.telPhone);
							$("#address").html(result.provinceName + result.cityName + result.areaName + result.address);
							$("#sendTime").html(result.sendTime == null ? "" : $.getLocalTime(result.sendTime));
							$(".returnReason").html(result.returnReason);
							$("#accountPrice").html(result.accountPrice);

							$("#returnPrice").html(result.productPrice);//应退金额
							$("#productPrice").html(result.returnPrice);//退货总金额

							$("#refundAccountPrice").html(result.refundAccountPrice);
							$("#orderPayCode").html(result.orderPayCode);
							$("#refundPrice").html(result.refundPrice);
							$("#totalPrice").html(result.totalPrice);
							var payType = "微信";
							if (result.payType == 'Small') {
								payType = "小程序";
							} else if (result.payType == 'Alipay') {
								payType = "支付宝";
							} else if (result.payType == 'Account') {
								payType = "成长基金";
							}

							$("#payType").html(payType);
							if (result.returnStatus == "Complete") {
								$("#refundTime").html($.getLocalTime(result.updateTime));
							}
							$("#updateBy").html(result.updateBy);
							$('#returnReasonType').html(result.returnReasonTypeDesc)
							$("#userExpressCompany").html(result.userExpressCompany);
							$("#userExpressCode").html(result.userExpressCode);
							if (result.returnStatus != "WaitingCheck")
								$(".div_yijian").hide();
							//显示图片
							var str = "";
							$.each(result.returnImgPath.split(','), function (index, item) {

								str += "<img src='" + item + "' style='height:150px' >";
							});
							$(".returnImgPath").html(str);
							$.each(result.returnType == "Return" ? result.sourceDetailList : result.detailList, function (index, item) {
								if (item.orderDetailStatus != 'WaitingSign') {
									allSend = false;
								}

								var updateBtn = "<a class='btn btn-success btn-update-desc  btn-width disabled' rod-id ='" + item.rodId + "' return-code='" + item.returnCode + "' style='width:80px;margin-left:0px;margin-right:5px;margin-top:2px;' ><i class='fa fa-arrow-circle-o-up'></i>修改</a>";
								var tr = "<tr><td>" + item.productName + "</td><td>" + item.skuCode + "</td><td>" + item.shortName + "</td><td>" + item.sizeName + "</td><td>" + (item.price == null ? "" : format_thousands(item.price)) + "</td><td>" + item.amount + "</td>"
								if (returnType == 'Return') {
									$("#sku_list thead").find(".sds").show();
									$("#sku_list thead").find(".srs").show();
									tr += "<td>" + item.orderDetailStatusStr + "</td><td>" + item.refundStatusStr + "</td>";
								}
								if (returnStatus != 'Cancel' && returnStatus != 'Reject' && returnStatus != 'WaitingCheck' && returnStatus != 'WaitingReturnGoods') {
									$("#sku_list thead").find(".wis").show();
									var qDesc = "<td class='questionDesc'><i class='fa fa-arrow-circle-o-up changeDesc'>..</i>" + (item.questionDesc == null ? "" : item.questionDesc) + "</td><td>" + updateBtn + "</td>";
									tr += qDesc;
								}


								tr += "</tr>"
								$("#sku_list tbody").append(tr);

							});
							$("#sku_list tbody").on("click", ".changeDesc", changeDesc);
							$("#sku_list tbody").on("click", ".btn-update-desc", updateDesc);
							//循环物流
							var str = "";
							if (result.logisticsList != null) {
								$.each(result.logisticsList, function (index, m) {
									str += '<div class="form-group  mrg-bt10 "><label class="control-label col-md-2" style="width:150px">物流公司：</label>' +
										'<div class="col-md-2 inline" >' + m.expressCompany +
										'</div>' +
										'<label class="control-label col-md-2" style="width:100px">物流单号：</label>' +
										'<div class="col-md-2 inline" >' + m.expressCode +
										'</div></div>';

								});
								$(".logisticsList").empty().append(str);
							} else {
								$(".logisticsList").parent().hide();
							}
						}
					}
				});
			};
			var changeDesc = function () {

				var p = $(this).parent().parent();
				$(p).find('.btn-update-desc').removeClass("disabled")
				var selectDesc = "<select name=questionDesc class='select2-choice'><option>二次销售</option><option>无标</option><option>可返厂</option><option>残品</option><option>其他问题</option></select><p style='display:none;margin-top:5px'><input name='qu' placeholder='输入退换货原因' maxlength='100' type='text'></p>";
				var t = $(p).find("td:eq(6)").html(selectDesc);

				$(p).find("[name=questionDesc]").change(function () {

					if ($(this).find("option:selected").text() == "其他问题") {
						$(this).parent().find("p").show();
					} else { $(this).parent().find("p").hide(); }
				});

			}

			var updateDesc = function () {
				var p = $(this).parent().parent();
				var rodId = $(this).attr('rod-id');
				var returnCode = $(this).attr('return-code');
				var selectText = $(p).find("[name=questionDesc]").val();
				var desc = selectText == "其他问题" ? $(p).find("[name=qu]").val() : selectText;
				if (desc == "") {
					$.alert("请输入处理方式")
					return false;
				}
				$.confirm("确认修改?", function () {
					$.ajax({
						type: "get",
						url: App.getContextPath() + "admin/returnorder/updateQuestionDesc.do",
						data: { rodId: rodId, desc: desc, returnCode: returnCode },
						async: true,
						success: function (result) {
							if (result.type == "error") {
								$.alert(result.extra);
							} else {
								$.alert("审核成功");
								location.reload();
							}
						}
					});

				});

			}

			var updateStatus = function () {
				if ($(this).hasClass('bt-retrunMoney')) {
					return false
				}
				var remark = $("[name=returnremark]").val();
				var status = $(this).attr("status");
				var isPass = status == "reject" ? false : true;
				if (wdtCode == "null") {
					$.alert("团购订单未同步到旺店通,请稍后审批");
					return false;
				}

				if (remark == "" && !isPass) {
					$.alert("请输入审批意见");
					return false;
				}
				$.confirm("确认审核操作?", function () {
					if (isPass && !allSend) {
						bootbox.dialog({
							message: "请到旺店通核实商品发货状态，处理后在确认",
							title: "订单状态确认",
							buttons: {
								success: {
									label: "已发货",
									className: "btn-success",
									callback: function () {
										$(".bootbox").modal("hide");
										orderStatus = "WaitingSign";
										auditReturnOrder(isPass, remark);
									}
								},
								danger: {
									label: "未发货",
									className: "btn-danger",
									callback: function () {
										$(".bootbox").modal("hide");
										orderStatus = "WaitingSend";
										auditReturnOrder(isPass, remark);
									}
								}
							}
						});
					} else {
						orderStatus = "WaitingSign";
						auditReturnOrder(isPass, remark);
					}

				});
			}
			var auditReturnOrder = function (isPass, remark) {
				$.ajax({
					type: "get",
					url: App.getContextPath() + "admin/returnorder/auditReturnOrder.do",
					data: { returnCode: id, passOrderReject: isPass, orderStatus: orderStatus, remark: remark, userId: userId },
					async: true,
					success: function (result) {
						if (result.type == "error") {
							$.alert(result.extra);
						} else {
							$.alert("审核成功");
							window.location.href = "return_order_list.html";
						}
					}
				});
			}
			var getReturnLogs = function (id) {
				$.ajax({
					type: "get",
					url: App.getContextPath() + "admin/returnorder/getReturnLogs.do",
					data: { returnCode: id },
					async: true,
					success: function (result) {
						var str = "";
						$.each(result, function (index, item) {
							if (item.remark == null) {
								item.remark = "";
							}

							str += '<tr><td>' + $.getLocalTime(item.createTime) + '</td>   <td>' + item.operation + '</td> <td>' + item.remark + '</td> <td>' + item.createBy + '</td></tr>';
						});
						$("#log_list tbody").empty().append(str);
					}
				});
			}
			var returnMoney = function () {
				var pid = $(this).attr("id");
				var transactionId, returnCode;
				console.log("id=" + pid);
				if (btnFlag) return false;
				$.ajax({
					type: "get",
					url: App.getContextPath() + "admin/returnorder/getReturnOrderMoneryById.do",
					data: { id: pid },
					success: function (result) {
						btnFlag = false;
						$("#returnMoney_config").find(".returnPrice").html(result.returnPrice);
						$("#returnMoney_config").find(".productPrice").html(result.productPrice);
						$("#returnMoney_config").find(".accountPrice").html(result.accountPrice);
						$("#returnMoney_config").find(".orderPayCode").html(result.orderPayCode);
						$("#returnMoney_config").find("[name=realPrice]").val(result.returnMode == 'OffLine' ? result.refundPrice : result.productPrice);
						$("#returnMoney_config").find("[name=realFundPrice]").val(result.returnMode == 'OffLine' ? result.refundAccountPrice : result.accountPrice);
						var pType;
						if ('WeChat' == result.payType) {
							pType = '微信支付';
						} else if ('Small' == result.payType) {
							pType = '小程序支付';

						} else if ('Alipay' == result.payType) {
							pType = '支付宝支付';

						} else {
							pType = '成长基金支付';
						}
						$("#returnMoney_config").find(".payType").html(pType);
						$("[name=returnPayType]").val(result.payType)
						$("#returnMoney_config").find(".totalPrice").html(result.totalPrice);
						$("[name=remark]").val('');
						transactionId = result.transactionId;
						returnCode = result.returnCode;
					},
					error: function (e) { btnFlag = false; }

				});



				$("#returnMoney_config").modal("show");
				$(".bt-updateMoney").unbind("click").click(function () {
					var realPrice = $("[name=realPrice]").val();
					var payType = $("[name=returnPayType]").val();
					var realFundPrice = $("[name=realFundPrice]").val();
					var remark = $("[name=remark]").val();
					if (realPrice == "") {
						$("#returnMoney_config").find("[name=realPrice]").parents(".form-group").addClass("has-error");
					}
					if (realFundPrice == "") {
						$("#returnMoney_config").find("[name=realFundPrice]").parents(".form-group").addClass("has-error");
					}
					if (remark == "") {
						$("#returnMoney_config").find("[name=remark]").parents(".form-group").addClass("has-error");
						return false;
					}
					if (realPrice == 0) {
						payType = 'WeChat';
					}
					$.confirm("确认退款操作?", function () {
						payType == 'Alipay' ? alipayRefund(pid, transactionId, returnCode, realPrice, realFundPrice, payType, remark)
						: weixinRefund(pid, realPrice, realFundPrice, payType, remark)
					});

				});
			};
			var alipayRefund = function (returnId, transactionId, returnCode, realPrice, realFundPrice, payType, remark) {
				if (btnFlag) return false;
				btnFlag = true;
				$.ajax({
					type: "get",
					url: App.getContextPath() + "admin/returnorder/alipayRefund.do",
					data: { returnId: returnId, returnCode: returnCode, transactionId: transactionId, refundPrice: realPrice, refundAccountPrice: realFundPrice, payType: payType, remark: remark },
					async: true,
					success: function (result) {
						btnFlag = false;
						$("#returnMoney_config").html(result)
						$("#returnMoney_config").modal("show");
					},
					error: function (e) { btnFlag = false; }
				});

			}
			var weixinRefund = function (pid, realPrice, realFundPrice, payType, remark) {
				if (btnFlag) return false;
				btnFlag = true;
				$.ajax({
					type: "get",
					url: App.getContextPath() + "admin/returnorder/returnMoney.do",
					data: { id: pid, refundPrice: realPrice, refundAccountPrice: realFundPrice, payType: payType, remark: remark },
					async: true,
					success: function (result) {
						btnFlag = false;
						if (result.type == 'error') {

							$.alert(result.extra);
							return
						}
						// $.alert("退款成功");
						// $("#returnMoney_config").modal("hide");
						// $("[name=realPrice]").val('');
						// $("[name=realFundPrice]").val('');
						// $("[name=remark]").val('');
						window.location.href = './return_order_list.html'
					},
					error: function (e) { btnFlag = false; }
				});

			}
			return {
				init: function () {
					App.init();
					id = $.getUrlParam("id");
					userId = $.getUrlParam("userId");
					orderStatus = $.getUrlParam("orderStatus");
					oId = $.getUrlParam("oId");
					wdtCode = $.getUrlParam("wdtCode");

					getDetail(id, userId, oId);
					getReturnLogs(id);
					$(".bt-retrunMoney").click(returnMoney)
					$(".btn-danger,.btn-success").click(updateStatus);
					$("#orderTelPhone").html($.getUrlParam("telPhone"));
				}
			}
		}();
		$(function () {
			$("#header").load("../head.html");
			///$("#sidebar").load("../menu.html");
			AddDetail.init();
		});
	</script>

	<!-- /JAVASCRIPTS -->
</body>

</html>